import request from '@/utils/request'
import { getToken } from '@/utils/token'
export const loginAPI = ({ mobile, code }) => request({
  url: '/v1_0/authorizations',
  method: 'POST',
  data: {
    mobile: mobile,
    code: code
  }
})
/**
 * 获取已选频道
 * @returns Promise对象
 * 注意:不强制要求用户登录
 */
export const getUserChannelListAPI = () => {
  return request({
    url: '/v1_0/user/channels',
    headers: {
      Authorization: `Bearer ${getToken()}`
    }
  })
}

export const allChannelListAPI = () => {
  return request({
    url: '/v1_0/channels'
  })
}

export const getArtucleListAPI = ({ channel_id, timestamp = new Date() }) => {
  return request({
    url: '/v1_0/articles',
    method: 'GET',
    headers: {
      Authorization: `Bearer ${getToken()}`
    },
    params: {
      channel_id,
      timestamp
    }
  })
}
export const dislikeArticleAPI = (artId) => request({
  url: '/v1_0/article/dislikes',
  method: 'POST',
  headers: {
    Authorization: `Bearer ${getToken()}`
  },
  data: {
    target: artId
  }
})
